using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;


namespace YATC
{
    /// <summary>
    /// This is a game component that implements IUpdateable.
    /// </summary>
    public class GameScene : Microsoft.Xna.Framework.DrawableGameComponent
    {
        public List<GameComponent> _Components;

        public GameScene(Game game)
            : base(game)
        {
            _Components = new List<GameComponent>();

            Enabled = false;
            Visible = false;
        }

        /// <summary>
        /// Allows the game component to perform any initialization it needs to before starting
        /// to run.  This is where it can query for any required services and load content.
        /// </summary>
        public override void Initialize()
        {
            // TODO: Add your initialization code here

            base.Initialize();
        }

   
        public override void Update(GameTime gameTime)
        {
            for (int i = 0; i < _Components.Count; i++)
            {
                if(_Components[i].Enabled)
                    _Components[i].Update(gameTime);
   
            }

            base.Update(gameTime);
        }

        public virtual void Show()
        {
            Enabled = true;
            Visible = true;
        }

        public virtual void Hide()
        {
            Enabled = false;
            Visible = false;
        }

        public override void Draw(GameTime gameTime)
        {
            for (int i = 0; i < _Components.Count; i++)
            {
                var c = _Components[i];
                if(c is DrawableGameComponent && ((DrawableGameComponent)c).Visible)
                    ((DrawableGameComponent)c).Draw(gameTime);
            }
            base.Draw(gameTime);
        }
    }
}